package com.ruoyi.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.OldPeopleOrder;
import com.ruoyi.system.service.IOldPeopleOrderService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 老年服务订单Controller
 * 
 * @author ruoyi
 * @date 2021-07-05
 */
@RestController
@RequestMapping("/system/Oldorder")
public class OldPeopleOrderController extends BaseController
{
    @Autowired
    private IOldPeopleOrderService oldPeopleOrderService;

    /**
     * 查询老年服务订单列表
     */
//    @PreAuthorize("@ss.hasPermi('system:Oldorder:list')")
    @GetMapping("/list")
    public TableDataInfo list(OldPeopleOrder oldPeopleOrder)
    {
        startPage();
        List<OldPeopleOrder> list = oldPeopleOrderService.selectOldPeopleOrderList(oldPeopleOrder);
        return getDataTable(list);
    }

    /**
     * 导出老年服务订单列表
     */
//    @PreAuthorize("@ss.hasPermi('system:Oldorder:export')")
    @Log(title = "老年服务订单", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(OldPeopleOrder oldPeopleOrder)
    {
        List<OldPeopleOrder> list = oldPeopleOrderService.selectOldPeopleOrderList(oldPeopleOrder);
        ExcelUtil<OldPeopleOrder> util = new ExcelUtil<OldPeopleOrder>(OldPeopleOrder.class);
        return util.exportExcel(list, "Oldorder");
    }

    /**
     * 获取老年服务订单详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:Oldorder:query')")
    @GetMapping(value = "/{oId}")
    public AjaxResult getInfo(@PathVariable("oId") Long oId)
    {
        return AjaxResult.success(oldPeopleOrderService.selectOldPeopleOrderById(oId));
    }

    /**
     * 新增老年服务订单
     */
//    @PreAuthorize("@ss.hasPermi('system:Oldorder:add')")
    @Log(title = "老年服务订单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OldPeopleOrder oldPeopleOrder)
    {oldPeopleOrder.setoState("0");
        return toAjax(oldPeopleOrderService.insertOldPeopleOrder(oldPeopleOrder));
    }

    /**
     * 修改老年服务订单
     */
//    @PreAuthorize("@ss.hasPermi('system:Oldorder:edit')")
    @Log(title = "老年服务订单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OldPeopleOrder oldPeopleOrder)
    {
        return toAjax(oldPeopleOrderService.updateOldPeopleOrder(oldPeopleOrder));
    }

    /**
     * 删除老年服务订单
     */
//    @PreAuthorize("@ss.hasPermi('system:Oldorder:remove')")
    @Log(title = "老年服务订单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{oIds}")
    public AjaxResult remove(@PathVariable Long[] oIds)
    {
        return toAjax(oldPeopleOrderService.deleteOldPeopleOrderByIds(oIds));
    }
}
